home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20041116-20060924 / 000307_fdc@columbia.edu_Thu Apr 20 10:20:49 2006.msg < prev    next >
Internet Message Format  |  2020-01-01  |  3KB

  1. Path: newsmaster.cc.columbia.edu!not-for-mail
  2. From: Frank da Cruz <fdc@columbia.edu>
  3. Newsgroups: comp.protocols.kermit.misc
  4. Subject: Re: speed of script execution
  5. Date: 20 Apr 2006 14:20:36 GMT
  6. Organization: Columbia University
  7. Lines: 54
  8. Message-ID: <slrne4f65k.djh.fdc@sesame.cc.columbia.edu>
  9. References: <1145524573.729587.320320@z34g2000cwc.googlegroups.com>
  10. Reply-To: fdc@columbia.edu
  11. NNTP-Posting-Host: sesame.cc.columbia.edu
  12. X-Trace: newsmaster.cc.columbia.edu 1145542836 11481 128.59.59.56 (20 Apr 2006 14:20:36 GMT)
  13. X-Complaints-To: postmaster@columbia.edu
  14. NNTP-Posting-Date: 20 Apr 2006 14:20:36 GMT
  15. User-Agent: slrn/0.9.8.0 (SunOS)
  16. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:15565
  17.  
  18. On 2006-04-20, tomviolin <rock_spambust_violin@yahoo.com> wrote:
  19. : Can anyone tell me why there is such a huge time discrepency between
  20. : the execution of the following scripts.  The only difference is the
  21. : curly braces.  I'm running on an ARM SBC from a flash drive, if that
  22. : makes any difference.
  23. :
  24. : ---- testx.ksc ----
  25. : #!/usr/bin/kermit +
  26. : {  assign \%p 1, set line  /dev/ttyAM\%p }
  27. : { close }
  28. : exit
  29. :
  30. : ---- testy.ksc ----
  31. : #!/usr/bin/kermit +
  32. : assign \%p 1, set line  /dev/ttyAM\%p
  33. : close
  34. : exit
  35. :
  36. : -- test results --
  37. : $ time ./testx.ksc
  38. : real    0m 0.60s
  39. : user    0m 0.04s
  40. : sys     0m 0.06s
  41. :
  42. : $ time ./testy.ksc
  43. : real    0m 0.09s
  44. : user    0m 0.05s
  45. : sys     0m 0.04s
  46. :
  47. : Yes, when I go back and forth between the two scripts, the times of
  48. : each stay consistent, so the second one shown above didn't just run
  49. : faster because it was second; if I go back and run testx.ksc again, it
  50. : takes 0.60s.
  51. :
  52. : Of course "don't use the curly braces" but this is part of a larger
  53. : system that I have distilled down to this very simple example, so
  54. : that's really not an option.
  55. :
  56. As in C, the braces mark a block, entry to and exit from which carries some
  57. setup and takedown cost.  When you have only one or two statements in the
  58. block, that cost is a lot higher, proportionally, than if you have a lot of
  59. statements in it.
  60.  
  61. Block structure is a convenience and an aid to writing readable source code,
  62. but it's not a necessity.  Every block structure can be decomposed into
  63. something more rudimentary and lest costly in execution, using GOTOs or
  64. whatever.  In fact, that's what happens internally anyway.  The only
  65. difference is that with true blocks, various buffers and variables and other
  66. context have to be stacked.
  67.  
  68. If you have encountered a serious bottleneck in a real application, let me
  69. know, maybe something can be done about it.
  70.  
  71. - Frank